<div class="pt15 pl15">当前位置：<span class="layui-breadcrumb"><a href="/">首页</a><a href="/admin/sys-role/index">角色管理</a></span></div>
  <div class="layui-fluid">
    <div class="layui-card p30">		
		<div class="border-b pb15 f22">角色管理</div>
		<div class="layui-row mt15">
			<div class="layui-col-xs12 layui-col-md9">
                <a class="layui-btn layui-btn-normal" href="/admin/sys-role/create">添加角色</a>
			</div>
			<div class="layui-col-xs12 layui-col-md3 text-r">
				<form class="layui-form " action="/admin/sys-role/index">				
					<div class="search content">
						<input type="text" name="name" value="" placeholder="请输入您要查询的关键字!" class="layui-input">
						<button class="layui-btn layui-btn-normal layui-icon layui-icon-search">  搜索</button>
					</div>
				</form>
			</div>
		</div>	
		<div class="layui-card-body p0 mt15">		 
			<table class="layui-table">					
				<thead>
					<tr>
					  <th>ID</th>
					  <th>名称</th>
					  <th>操作</th>
					</tr> 
				</thead>
			  <tbody>
				<?php foreach($data['pagedata'] as $role){?>  
				<tr>
				  <td><?= $role['id'] ?></td>
				  <td><?= $role['name'] ?></td>
				  <td>
					<a class="layui-btn layui-btn-normal layui-btn-xs" href="/admin/sys-role/update?id=<?= $role['id']?>"><i class="layui-icon layui-icon-edit"></i>编辑</a>
					<a class="layui-btn layui-btn-xs" href="/admin/sys-role/role-auth?roleid=<?= $role['id']?>"><i class="layui-icon layui-icon-auz"></i>权限管理</a>	
					<a class="layui-btn layui-btn-danger layui-btn-xs delete" data-id="<?= $role['id']?>"><i class="layui-icon layui-icon-delete"></i>删除</a>
				  </td>
				</tr>
				<?php }?>
				</tbody>
			</table>			
			<div class="p-tradelist-pager text-c"><?= $page?></div>		
		</div>
    </div>
  </div>
<script>
$(".delete").on('click',function(){
    var id = $(this).attr('data-id');
    layer.confirm('您确定要删除该条数据', {btn: ['删除', '取消' ]}, function(index, layero){
        $params = JSON.stringify({'id':id});
        second_region_back = ajaxSynchroRequest("/admin/sys-role/delete",$params);
        if(second_region_back.success==1){
            layer.msg(second_region_back.msg);
            layer.close(index);
            window.location.reload();
        }
    });
});
</script>

